// pages/browse/browse.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    x: 8,
    detail: [],
    how: [],
    why: [],
    pica: [],
    xia: [],
    quanbu: [],
    agopageSub: [],
    comment: [],
    morepage: [],
    lishilist: wx.getStorageSync('lishi'),
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    wx.showLoading({
      title: '加载中',
    })
    // http://cloud.agopage.com/6b83fd3bc06260ec/agopageDetail?userInfoId=5fb186153f
    wx.request({
      url: 'http://cloud.agopage.com/6b83fd3bc06260ec/agopageDetail?userInfoId=5fb186153f',
      data: {
        agopageId: this.data.lishilist[0].id
      },
      success: (res) => {
        // console.log(res.data.data);
        this.setData({
          detail: res.data.agopage,
        })
      },
      complete: () => {
        wx.hideLoading()
      }
    })
    wx.request({
      url: 'http://cloud.agopage.com/6b83fd3bc06260ec/agopageDetail?userInfoId=5fb186153f',
      data: {
        agopageId: this.data.lishilist[1].id
      },
      success: (res) => {
        // console.log(res.data.data);
        this.setData({
          quanbu: res.data.agopage,
        })
      },
    })
    wx.request({
      url: 'http://cloud.agopage.com/6b83fd3bc06260ec/agopageDetail?userInfoId=5fb186153f',
      data: {
        agopageId: this.data.lishilist[2].id
      },
      success: (res) => {
        // console.log(res.data.data);
        this.setData({
          agopageSub: res.data.agopage,
        })
      },
    })
    wx.request({
      url: 'http://cloud.agopage.com/6b83fd3bc06260ec/agopageDetail?userInfoId=5fb186153f',
      data: {
        agopageId: this.data.lishilist[3].id
      },
      success: (res) => {
        // console.log(res.data.data);
        this.setData({
          comment: res.data.agopage,
        })
      },
    })
    wx.request({
      url: 'http://cloud.agopage.com/6b83fd3bc06260ec/agopageDetail?userInfoId=5fb186153f',
      data: {
        agopageId: this.data.lishilist[4].id
      },
      success: (res) => {
        // console.log(res.data.data);
        this.setData({
          morepage: res.data.agopage,
        })
      },
    })
    wx.request({
      url: 'http://cloud.agopage.com/6b83fd3bc06260ec/agopageDetail?userInfoId=5fb186153f',
      data: {
        agopageId: this.data.lishilist[5].id
      },
      success: (res) => {
        // console.log(res.data.data);
        this.setData({
          pica: res.data.agopage,
        })
      },
    })
    wx.request({
      url: 'http://cloud.agopage.com/6b83fd3bc06260ec/agopageDetail?userInfoId=5fb186153f',
      data: {
        agopageId: this.data.lishilist[6].id
      },
      success: (res) => {
        // console.log(res.data.data);
        this.setData({
          why: res.data.agopage,
        })
      },
    })
    wx.request({
      url: 'http://cloud.agopage.com/6b83fd3bc06260ec/agopageDetail?userInfoId=5fb186153f',
      data: {
        agopageId: this.data.lishilist[7].id
      },
      success: (res) => {
        // console.log(res.data.data);
        this.setData({
          how: res.data.agopage,
        })
      },
    })
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },
  onRefresh:function(){
    //导航条加载动画
    wx.showNavigationBarLoading()
    //loading 提示框
    wx.showLoading({
      title: 'Loading...',
    })
    console.log("下拉刷新啦");
    setTimeout(function () {
      wx.hideLoading();
      wx.hideNavigationBarLoading();
      //停止下拉刷新
      wx.stopPullDownRefresh();
    }, 2000)
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {
    this.onRefresh();
    wx.request({
      url: 'http://cloud.agopage.com/6b83fd3bc06260ec/agopageDetail?userInfoId=5fb186153f',
      data: {
        agopageId: this.data.lishilist[0].id
      },
      success: (res) => {
        // console.log(res.data.data);
        this.setData({
          detail: res.data.agopage,
        })
      },
    })
    wx.request({
      url: 'http://cloud.agopage.com/6b83fd3bc06260ec/agopageDetail?userInfoId=5fb186153f',
      data: {
        agopageId: this.data.lishilist[1].id
      },
      success: (res) => {
        // console.log(res.data.data);
        this.setData({
          quanbu: res.data.agopage,
        })
      },
    })
    wx.request({
      url: 'http://cloud.agopage.com/6b83fd3bc06260ec/agopageDetail?userInfoId=5fb186153f',
      data: {
        agopageId: this.data.lishilist[2].id
      },
      success: (res) => {
        // console.log(res.data.data);
        this.setData({
          agopageSub: res.data.agopage,
        })
      },
    })
    wx.request({
      url: 'http://cloud.agopage.com/6b83fd3bc06260ec/agopageDetail?userInfoId=5fb186153f',
      data: {
        agopageId: this.data.lishilist[3].id
      },
      success: (res) => {
        // console.log(res.data.data);
        this.setData({
          comment: res.data.agopage,
        })
      },
    })
    wx.request({
      url: 'http://cloud.agopage.com/6b83fd3bc06260ec/agopageDetail?userInfoId=5fb186153f',
      data: {
        agopageId: this.data.lishilist[4].id
      },
      success: (res) => {
        // console.log(res.data.data);
        this.setData({
          morepage: res.data.agopage,
        })
      },
    })
    wx.request({
      
      url: 'http://cloud.agopage.com/6b83fd3bc06260ec/agopageDetail?userInfoId=5fb186153f',
      data: {
        agopageId: this.data.lishilist[5].id
      },
      success: (res) => {
        // console.log(res.data.data);
        this.setData({
          pica: res.data.agopage,
        })
      },
    })
    wx.request({
      url: 'http://cloud.agopage.com/6b83fd3bc06260ec/agopageDetail?userInfoId=5fb186153f',
      data: {
        agopageId: this.data.lishilist[6].id
      },
      success: (res) => {
        // console.log(res.data.data);
        this.setData({
          why: res.data.agopage,
        })
      },
    })
    wx.request({
      url: 'http://cloud.agopage.com/6b83fd3bc06260ec/agopageDetail?userInfoId=5fb186153f',
      data: {
        agopageId: this.data.lishilist[7].id
      },
      success: (res) => {
        // console.log(res.data.data);
        this.setData({
          how: res.data.agopage,
        })
      },
    })
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
    wx.request({
      url: 'http://cloud.agopage.com/6b83fd3bc06260ec/agopageDetail?userInfoId=5fb186153f',
      data: {
        agopageId: this.data.lishilist[this.data.x].id
      },
      success: (res) => {
        // console.log(res.data.data);
        this.setData({
          xia: res.data.agopage,
          x: this.data.x + 1
        })
      },
    })
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})